
***************************************************************
*******Firm-Firm Customer Distance - by individual customers

clear all
use Figure_A10_Data

order gvkey1  gvkey2 year sim 
rename sim firm_firm_similarity


gen same_category = category1==category2

egen Within_Category_Similarity = mean(firm_firm) if firm_firm_similarity<.25 & firm_firm_similarity>.001 & same_cat==1, by(category1)

label var Within_Category_Similarity "Average Within-Category Firm Similarity"
graph hbar Within_Category_Similarity, over(category1) 
graph export "Output/Within_Category_Similarity.png", replace


